import React, { Component, createRef } from "react";

class App extends Component {
  file = createRef();

  handleClick = () => {
    // this.file.current.files[0]文件信息
    console.log(this.file.current.files[0]);
  };

  render() {
    return (
      <>
        <h3>文件上传</h3>
        {/* 只有文件上传的时候，必须使用非受控组件 */}
        <input type="file" ref={this.file} />
        <button onClick={this.handleClick}>btn</button>
      </>
    );
  }
}

export default App;
